//:C07:UniqueList.cpp
// Testing list's unique() function.
#include <iostream>
#include <iterator>
#include <list>
#include <ostream>
using namespace std;

int a[] = {1, 3, 1, 4, 1, 5, 1, 6, 1};
const int ASZ = sizeof a / sizeof *a;

int main(void)
{
    // For output
    ostream_iterator<int> out(cout, " ");
    list<int> li(a, a + ASZ);
    li.unique();
    // Oops! No duplicates removed:
    copy(li.begin(), li.end(), out);
    cout << endl;
    // Must sort it first
    li.sort();
    copy(li.begin(), li.end(), out);
    cout << endl;
    // Now unique() will have an effect:
    li.unique();
    copy(li.begin(), li.end(), out);
    cout << endl;
}